//
//  CollectModel.m
//  XIWenLeJian
//
//  Created by lanou3g on 15/11/17.
//  Copyright © 2015年 蓝足. All rights reserved.
//

#import "CollectModel.h"
#import "VideoModel.h"
@interface CollectModel ()

@property (nonatomic, strong)NSMutableArray *dataArray;

@end

@implementation CollectModel

- (NSMutableArray *)dataArray
{
    if (_dataArray == nil) {
        _dataArray = [NSMutableArray array];
    }
    return _dataArray;
}

- (NSMutableArray *)content
{
    if (_content == nil) {
        _content = [NSMutableArray array];
    }
    return _content;
}

- (instancetype)initWithDic:(NSDictionary *)dictionary nameString:(NSString *)nameString
{
    self = [super init];
    if (self) {
        self.content = nil;
        self.name = nameString;
        NSMutableArray *array = [NSMutableArray array];
        if ([dictionary allKeys].count) {
            for (NSString *key in [dictionary allKeys]) {
                [array addObject:[dictionary objectForKey:key]];
            }
            if ([nameString isEqualToString:@"videos"]) {
                [self.content addObjectsFromArray:[VideoModel freshListArray:array]];
            }
        }
    }
    return self;
}

+ (instancetype)collectWithDic:(NSDictionary *)dictionary nameString:(NSString *)nameString
{
    return [[self alloc]initWithDic:dictionary nameString:nameString];
}

+ (NSArray *)collectWithDic:(NSDictionary *)collectDic
{
    NSMutableArray *array = [NSMutableArray array];
    for (NSString *str in [collectDic allKeys]) {
        [array addObject:[self collectWithDic:[collectDic objectForKey:str] nameString:str]];
    }
    return array;
}

@end
